/* -----------------------------------------------------------------------
 *
 * Include the following lines in your makefile:
 *
 * testunittest2: unittest2.c dominion.o rngs.o
 *      gcc -o testunittest2 -g  unittest2.c dominion.o rngs.o $(CFLAGS)
 * -----------------------------------------------------------------------
 */

//checking drawCard function

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

// set NOISY_TEST to 0 to remove printfs from output
#define NOISY_TEST 1

int main() {
    int i;
    int seed = 1000;
    int numPlayer = 2;
    int p, r, handCount;
    int k[10] = {adventurer, council_room, feast, gardens, mine
        , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    int maxHandCount = 5;

    printf ("TESTING drawCard() function:\n");

    memset(&G, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
    G.handCount[p] = 0;         // set the number of cards on hand

    for (p = 0; p < numPlayer; p++)
    {
        for (handCount = 1; handCount <= maxHandCount; handCount++)
        {
#if (NOISY_TEST == 1)
                printf("Expected hand count: %d\n", handCount);
#endif
//will check the number of cards in players hand
                assert(drawCard(p, &G) == 0);

#if (NOISY_TEST == 1)
                printf("Hand count:  %d \n", G.handCount[p]);

#endif
                assert(G.handCount[p] == handCount);
        }
    }

    printf("All tests passed!\n");

    return 0;
}
